﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using XXX.Models.XXXEntities;
using XXX.Bo;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace XXX.api.Controllers
{


    //获得当前组织列表
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class AA_GetOrgListController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<AA_GetOrgListController> _logger;
        public AA_GetOrgListController(ILogger<AA_GetOrgListController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpGet]
        public Models.RetModel Get()
        {
            Models.RetModel ret = DBService.AA_GetOrgList();

            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }


    //获得仓库
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class AA_GetWarehouseByUserController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<AA_GetWarehouseByUserController> _logger;
        public AA_GetWarehouseByUserController(ILogger<AA_GetWarehouseByUserController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpGet]
        public Models.RetModel Get(string cOrg,string cUserid)
        {
            Models.RetModel ret = DBService.AA_GetWarehouseByUser(cOrg,cUserid);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }


    //获得仓库名称
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class AA_GetWareNameByCodeController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<AA_GetWareNameByCodeController> _logger;
        public AA_GetWareNameByCodeController(ILogger<AA_GetWareNameByCodeController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpGet]
        public Models.RetModel Get(string cOrg, string cWhCode)
        {
            Models.RetModel ret = DBService.AA_GetWareNameByCode(cOrg, cWhCode);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }
    //获得货位名称
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class AA_GetPosCodeByCodeController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<AA_GetPosCodeByCodeController> _logger;
        public AA_GetPosCodeByCodeController(ILogger<AA_GetPosCodeByCodeController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpGet]
        public Models.RetModel Get(string cOrg, string cWhCode,string cPosCode)
        {
            Models.RetModel ret = DBService.AA_GetPosCodeByCode(cOrg, cWhCode, cPosCode);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }


   
    //读取条码内容
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class AA_GetBarcodeController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<AA_GetBarcodeController> _logger;
        public AA_GetBarcodeController(ILogger<AA_GetBarcodeController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpGet]
        public Models.RetModel Get(string cOrg,string cbarcode)
        {
             
            Models.RetModel ret = DBService.AA_GetBarcode(cOrg,cbarcode);
            return ret;
             
        }

    }

    //货位调整
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class ST_PositionChangeController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<ST_PositionChangeController> _logger;
        public ST_PositionChangeController(ILogger<ST_PositionChangeController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpPost]
        public Models.RetModelbool Post(PuArrivalBarcode model)
        {
         
            Models.RetModelbool ret = WMSService.ST_PositionChange(model);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }
    //读取条码内容，带下级的条码
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class GetBarcodeBoxController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<GetBarcodeBoxController> _logger;
        public GetBarcodeBoxController(ILogger<GetBarcodeBoxController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpGet]
        public Models.RetModel Get(string cbarcode, string clx)
        {
            BarcodeManager barcode = new BarcodeManager();
            Models.RetModel ret = barcode.GetBarcodeBox(cbarcode, clx);
            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }


    //拆箱
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class ChaiXiangController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<ChaiXiangController> _logger;
        public ChaiXiangController(ILogger<ChaiXiangController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpPost]
        public Models.RetModelbool Post(ScanBarcodeChaiXiang model)
        {
            BarcodeManager barcode = new BarcodeManager();
            Models.RetModelbool ret = barcode.ChaiXiang(model);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }

    //拆箱
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class BingXiangController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<BingXiangController> _logger;
        public BingXiangController(ILogger<BingXiangController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpPost]
        public Models.RetModelbool Post(ScanBarcodeBingXiang model)
        {
            BarcodeManager barcode = new BarcodeManager();
            Models.RetModelbool ret = barcode.BingXiang(model);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }

    //上架
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class PositionUpController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<PositionUpController> _logger;
        public PositionUpController(ILogger<PositionUpController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpPost]
        public Models.RetModelbool Post(PostionChange model)
        {
            BarcodeManager barcode = new BarcodeManager();
            Models.RetModelbool ret = barcode.PositionUp(model);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }

    //读取或为条码内容
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class PositionDownController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<PositionDownController> _logger;
        public PositionDownController(ILogger<PositionDownController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpPost]
        public Models.RetModelbool Post(PostionChange model)
        {
            BarcodeManager barcode = new BarcodeManager();
            Models.RetModelbool ret = barcode.PositionDown(model);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }
    //读取或为条码内容
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class GetPositionInvBarController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<GetPositionInvBarController> _logger;
        public GetPositionInvBarController(ILogger<GetPositionInvBarController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpGet]
        public Models.RetModel Get(string cposcode)
        {
            BarcodeManager barcode = new BarcodeManager();
            Models.RetModel ret = barcode.GetPositionInvBar(cposcode);
            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }


    //现存量查询
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class Rep_GetInvStockController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<Rep_GetInvStockController> _logger;
        public Rep_GetInvStockController(ILogger<Rep_GetInvStockController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpGet]
        public Models.RetModel Get(string corg,string cwhcode,string cinvcode)
        {
           
            Models.RetModel ret = DBService.Rep_GetInvStock(corg,cwhcode, cinvcode);
            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }


    //货位查询
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class Rep_GetInvPosStockController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<Rep_GetInvPosStockController> _logger;
        public Rep_GetInvPosStockController(ILogger<Rep_GetInvPosStockController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpGet]
        public Models.RetModel Get(string corg, string cwhcode,string cposcode, string cinvcode)
        {

            Models.RetModel ret = DBService.Rep_GetInvPosStock(corg, cwhcode, cposcode, cinvcode);
            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class OtherOutRD09Controller : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<OtherOutRD09Controller> _logger;
        public OtherOutRD09Controller(ILogger<OtherOutRD09Controller> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }
        [HttpPost]
        public Models.RetModelbool Post(PuArrivalBarcode model)
        {

            Models.RetModelbool ret = WMSService.OtherOutRD09(model);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }
    }

    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class OtherInRD08Controller : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<OtherInRD08Controller> _logger;
        public OtherInRD08Controller(ILogger<OtherInRD08Controller> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }
        [HttpPost]
        public Models.RetModelbool Post(PuArrivalBarcode model)
        {

            Models.RetModelbool ret = WMSService.OtherInRD08(model);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }
    }

    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class MaterialOutRD11Controller : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<MaterialOutRD11Controller> _logger;
        public MaterialOutRD11Controller(ILogger<MaterialOutRD11Controller> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }
        [HttpPost]
        public Models.RetModelbool Post(PuArrivalBarcode model)
        {

            Models.RetModelbool ret = WMSService.MaterialOutRD11(model);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }
    }

    /// <summary>
    /// 获取盘点单信息
    /// </summary>
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class ST_GetPanDianController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<ST_GetPanDianController> _logger;
        public ST_GetPanDianController(ILogger<ST_GetPanDianController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }
        [HttpGet]
        public Models.RetModel Get(string corg,string ccode)
        {
              
            Models.RetModel ret = DBService.ST_GetPanDian(corg,ccode);
            return ret;
            //return ReturnStd.Success(jsonstr);
        }
    }

    /// <summary>
    /// 获取盘点明细
    /// </summary>
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class ST_GetPanDianDetailController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<ST_GetPanDianDetailController> _logger;
        public ST_GetPanDianDetailController(ILogger<ST_GetPanDianDetailController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }
        [HttpGet]
        public Models.RetModel Get(string corg,string ccode)
        {

            Models.RetModel ret = DBService.ST_GetPanDianDetail(corg,ccode);
            return ret;
            //return ReturnStd.Success(jsonstr);
        }
    }

    /// <summary>
    /// 获取盘点条码
    /// </summary>
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class GetPanDianBarcodeController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<GetPanDianBarcodeController> _logger;
        public GetPanDianBarcodeController(ILogger<GetPanDianBarcodeController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }
        [HttpGet]
        public Models.RetModel Get(string ccode)
        {

            Models.RetModel ret = DBService.GetPanDian_barcodes(ccode);
            return ret;
            //return ReturnStd.Success(jsonstr);
        }
    }

    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class ST_PanDianUpdateController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<ST_PanDianUpdateController> _logger;
        public ST_PanDianUpdateController(ILogger<ST_PanDianUpdateController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }
        [HttpPost]
        public Models.RetModelbool Post(PanDianVouch model)
        {
            //写入盘点明细。包含货位
            //更新U8盘点单
            Models.RetModelbool ret = WMSService.ST_PanDianUpdate(model);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }
    }

    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class ST_PanDianDelController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<ST_PanDianDelController> _logger;
        public ST_PanDianDelController(ILogger<ST_PanDianDelController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }
        [HttpGet]
        public Models.RetModelbool Get(string corg,string ccode)
        {
            //写入盘点明细。包含货位
            //更新U8盘点单
            Models.RetModelbool ret = WMSService.ST_PanDianDel(corg,ccode);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }
    }
}
